package operator;

import book.BookList;

import java.util.Scanner;

public class ReturnOperator implements Operator{

    public void work(BookList bookList) {

        System.out.println("------归还图书------");
        System.out.println("请输入要归还图书的书名：");
        Scanner sc = new Scanner(System.in);
        String s = sc.nextLine();

        int i = 0;
        int p = bookList.getUsebook();
        for ( i = 0; i < p; i++) {
            if(s.equals(bookList.getBooks(i).getName())) {
                break;
            }
        }
        if(i == p) {
            System.out.println("书架中没有该书");
            return;
        }
        bookList.getBooks(i).setIsborrow(false);
        System.out.println("归还成功");
    }


}
